<template>
  <div class="gallery-wrapper" @click.self="$emit('close-gallery')">
      <div class="gallery-content">
        <swiper :options="swiperOption">
            <swiper-slide v-for="item of imgList" :key="item.id">
              <img class="gallery-content-img"
                     :src="item.uri"
                     alt="">
            </swiper-slide>
          <div class="swiper-pagination"  slot="pagination"></div>
        </swiper>
      </div>
  </div>
</template>

<script>
  export default {
    name: "Gallery",
    props: {
      imgList: {
        type: Array,
        default() {
          return [
            {
              id: "001",
              uri: "http://img1.qunarzz.com/sight/p0/1501/66/b022755b6d3283fb1215306628edb00c.water.jpg_r_800x800_d31f7029.jpg"
            },
            {
              id: "002",
              uri: "http://img1.qunarzz.com/sight/p0/1501/8a/ccd6838daea0cc97c89076bae7084d79.water.jpg_r_800x800_3e201966.jpg"
            }
          ]
        }
      }
    },
    data() {
      return {
        swiperOption: {
          autoHeight: true,
          pagination: ".swiper-pagination",
          paginationType : 'fraction',
          observer:true,
          observeParents:true
        }
      }
    }
  }
</script>

<style lang="scss" scoped>

  .swiper-pagination {
    color: #ffffff;
    left: 0;
    bottom: -2rem;
  }

  .swiper-container {
    overflow: inherit;
  }

  .gallery-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    z-index: 10;
    .gallery-content {
      .gallery-content-img {
        width: 100%;
      }
    }
  }
</style>